import 'package:flutter_archer/data/repository/user_repository.dart';
import 'package:flutter_archer/routes/routes.dart';
import 'package:get/get.dart';

class SplashController extends GetxController {
  final UserRepository userRepository;
  SplashController({required this.userRepository});

  @override
  void onReady() async {
    super.onReady();

    await Future.delayed(Duration(milliseconds: 2000));
    bool hasLogin = await userRepository.hasLogin();
    try {
      if (hasLogin) {

        Get.toNamed(Routes.HOME);
      } else {
        Get.toNamed(Routes.AUTH);
      }
    } catch (e) {
      Get.toNamed(Routes.AUTH);
    }
  }
}
